package net.lwf.hibernate.dao;

import java.util.List;


import net.lwf.exception.ExceptionUtil;
import net.lwf.hibernate.entity.lookup.Lookup;
import net.lwf.hibernate.util.HibernateUtil;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;


public class LookupDAO extends BaseDAO {
	
	@SuppressWarnings("unchecked")
	public List<Lookup> getLookupData(String group) {
		List<Lookup> data = null;
	    Session session = HibernateUtil.getSessionFactory().openSession();
	    try {
	    	Criteria criteria = session.createCriteria(Lookup.class);
	    	criteria.add(Restrictions.eq("group", group));
	    	criteria.add(Restrictions.eq("status", "ACTIVE").ignoreCase());
	    	data = criteria.list();
	    }
	    catch(HibernateException hex) {
	    	hex.printStackTrace();
	    	ExceptionUtil.logAndThrowException(LookupDAO.class, hex);
	    }
	    finally {
	    	if(session != null) {
	    		session.close();
	    	}
	    }
		return data;
	}

} //LookupDAO
